<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>用户注册</title>
		<link rel="stylesheet" href="css/login.css" />
	</head>
	<body>
		<div class="register-box">
			<h1>用户注册</h1>
			<div class="item">
				<input placeholder="用户名" id="loginName" />
			</div>
			<div class="item">
				<input placeholder="密码" id="loginPassword" />
			</div>
			<div class="item">
				<input placeholder="真实姓名" id="realName" />
			</div>
			<div class="item">
				<input placeholder="昵称" id="nickName" />
			</div>
			<div class="item">
				<input placeholder="手机号码" id="userPhone" />
			</div>
			<div class="item">
				<input placeholder=" 邮箱" id="userEmail" />
			</div>
			<a id="register">立即注册</a>
		</div>
		<script src="js/jquery-1.11.1.min.js"></script>
		<script src="js/common.js"></script>
		<script>
			$("#register").on('click', function() {
				var $loginName = $("#loginName").val();
				var $loginPassword = $("#loginPassword").val();
				var $realName = $("#realName").val();
				var $nickName = $("#nickName").val();
				var $userPhone = $("#userPhone").val();
				var $userEmail = $("#userEmail").val();
				var postData = {
					loginName: $loginName,
					loginPassword: $loginPassword,
					realName: $realName,
					nickName: $nickName,
					userPhone: $userPhone,
					userEmail: $userEmail
				}
				// console.log(postData)
				if ($loginName.length == 0) {
					tips("用户名不能为空！")
				} else if ($loginPassword.length == 0) {
					tips("密码不能为空！")
				} else {
					$.ajax({
						url: url + 'adminUser/insert',
						type: 'POST',
						contentType: "application/json",
						data: JSON.stringify(postData),
						success: function(res) {
							// console.log(res)
							if (res.code != 200) {
								tips("创建失败！请您重新尝试")
							} else {
								tips(res.message);
								setTimeout(function(){
									window.location.href = "login.html";
								},800)
							}
						}
					})
				}
			})
		</script>
	</body>
</html>
